package com.interagriculture.controller;

import com.interagriculture.annotation.AdminVerify;
import com.interagriculture.common.Result;
import com.interagriculture.entity.StudioInfo;
import com.interagriculture.service.StudioInfoService;
import com.interagriculture.service.UserInfoService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author 11 2024/11/12
 */
@RestController
@RequestMapping("/adminStudio")
public class AdminStudioInfoController {


    @Resource
    private StudioInfoService studioInfoService;

    @PostMapping("/saveOrUpdate")
    @AdminVerify
    public Result saveOrUpdate(
            Integer id,
            String briefIntroduction,
            String address,
            @RequestPart(required = false) MultipartFile picture){
        StudioInfo studioInfo = new StudioInfo();
        studioInfo.setId(id);
        studioInfo.setAddress(address);
        studioInfo.setBriefIntroduction(briefIntroduction);
        studioInfoService.saveOrUpdateInfo(studioInfo,picture);
        return Result.ok();
    }
}
